package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: H_tao_X
 * Date: 2022-11-17
 * Time: 21:14
 */

/**
 * 通过 构造 方法 注入
 */
@Controller
public class UserController3 {

    // 1.先定义 注入的 对象
    private Service service;
    // 2. 构造 方法:[如果当前类中只存在一个构造方法，那么@Autowired可以省略]
    @Autowired
    public UserController3(Service service) {
        this.service = service;
    }
    public void sayHi() {
        service.sayHi();
    }
}
